use rstest::rstest;

use crate::tests::fixtures::{RANDOM_OFFSETS, RANDOM_USIZES};
use crate::tiling::SlotGrid;

#[rstest]
#[case::zero_offset(
    (RANDOM_USIZES[0] + 1, RANDOM_USIZES[1] + 1),
    (0isize, 0isize),
    (RANDOM_USIZES[0] + 1, RANDOM_USIZES[1] + 1),
)]
#[case::an_offset(
    (RANDOM_USIZES[2] + 1, RANDOM_USIZES[3] + 1),
    RANDOM_OFFSETS[0],
    (
        ((RANDOM_USIZES[2] + 1) as isize + RANDOM_OFFSETS[0].0)
        as usize,
        ((RANDOM_USIZES[3] + 1) as isize + RANDOM_OFFSETS[0].1)
        as usize,
    ),
)]
fn test_offset_coordinates(
    #[case] coordinates: (usize, usize),
    #[case] offset: (isize, isize),
    #[case] expected: (usize, usize),
) {
    let result: (usize, usize) = SlotGrid::offset_coordinates(coordinates, offset);

    assert_eq!(result, expected);
}
